package jmine.tec.json;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Implementacao auxiliar para JSON
 * @author takeshi
 */
public abstract class AbstractJSONObject implements JSON {

    /**
     * {@inheritDoc}
     */
    public int getSize() {
        return getPropertyNames().size();
    }

    /**
     * {@inheritDoc}
     */
    public Collection<JSON> getPropertyValues() {
        return getAllProperties().values();
    }

    /**
     * {@inheritDoc}
     */
    public Map<String, JSON> getAllProperties() {
        Collection<String> keys = getPropertyNames();
        Map<String, JSON> map = new HashMap<String, JSON>(keys.size());
        for (String key : keys) {
            JSON json = getProperty(key);
            map.put(key, json);
        }
        return map;
    }

}
